package com.sks.service.news.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sks.bean.pojo.News;
import com.sks.dao.news.NewsDao;
import com.sks.service.base.BaseService;
import com.sks.service.news.NewsService;

@Service
@Transactional
public class NewsServiceBean extends BaseService<News> implements NewsService{

	private NewsDao newsDao;
	
	@Override
	public NewsDao getNewsDao() {
		return newsDao;
	}

	@Override
	@Resource(name = "newsDao")
	public void setNewsDao(NewsDao newsDao) {
		this.newsDao=newsDao;
		this.setDao(newsDao);
		
	}

	/**
	 * @param visible
	 */
	public List<News> findTopNews(Boolean visible) {
		StringBuffer jpql = new StringBuffer(" o.parentArea is null");
		if (null == visible){
			return newsDao.getScrollData(-1,-1,jpql.toString(),null).getResultlist();
		}else {
			jpql.append(" and o.visible =?1");
			return newsDao.getScrollData(-1, -1, jpql.toString(), 
					new Object[]{visible}).getResultlist();
		}
	}

}
